package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.RiskService;
import com.woniu.p2p.entity.Invest;
import com.woniu.p2p.entity.InvestRisk;
import com.woniu.p2p.mapper.InvestMapper;
import com.woniu.p2p.mapper.InvestRiskMapper;
import com.woniu.p2p.vo.InvestRiskAndInvestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class RiskServiceImpl implements RiskService {

    @Autowired
    InvestRiskMapper investRiskMapper;
    @Autowired
    InvestMapper investMapper;


    @Override
    public PageInfo<InvestRiskAndInvestVo> findAllInvestRiskAndInvest(Integer start, Integer num, String riskstatus, Date predate, Date nextdate, String riskkeyword) {
        PageHelper.startPage(start,num);
        List<InvestRiskAndInvestVo> list = investRiskMapper.findAllInvestRisk(riskstatus, predate, nextdate, riskkeyword);
        PageInfo<InvestRiskAndInvestVo> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<InvestRiskAndInvestVo> findAllInvestAndRisk(int[] id) {
        List<InvestRiskAndInvestVo> allInvestAndRiskById = investRiskMapper.findAllInvestAndRiskById(id);
        return allInvestAndRiskById;
    }

    @Override
    public int deleteRiskById(Integer id) {
        return investRiskMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Invest findAllInvestById(int id) {
        return investMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertRisk(InvestRisk investRisk) {
        return investRiskMapper.insert(investRisk);
    }

    @Override
    public List<Invest> findAllInvest() {
        return investMapper.selectAll();
    }

    @Override
    public List<InvestRisk> selectAll() {
        return investRiskMapper.selectAll();
    }
}
